package com.luanye.enjoy.controller;

import com.luanye.enjoy.constants.CommentConst;
import com.luanye.enjoy.entity.Comment;
import com.luanye.enjoy.service.CommentService;
import com.luanye.enjoy.vo.RespBean;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/comment")
public class CommentController {

    @Autowired
    private CommentService commentService;

    @GetMapping("/commentList")
    public RespBean commentList(Long articleId, Integer pageNum, Integer pageSize){
        return commentService.commentList(CommentConst.ARTICLE_COMMENT,articleId,pageNum,pageSize);
    }

    @PostMapping("/add/{openid}")
    public RespBean addComment(@RequestBody Comment comment, @PathVariable("openid") String openid){
        return commentService.addComment(comment,openid);
    }

    @GetMapping("/num/{articleId}")
    public RespBean getCommentNum(@PathVariable("articleId") Long articleId){
        return commentService.getNum(articleId);
    }

}